< previous page page_898 next page >

Page 898
Listing A.24. continued
        SQLVBMain.CommonDialog1.DialogTitle = cLoadMsg
        SQLVBMain.CommonDialog1.DefaultExt = "SQV"
        SQLVBMain.CommonDialog1.Filter = "SQLVB File|*.SQV"
        SQLVBMain.CommonDialog1.ShowOpen
        cEditFile = SQLVBMain.CommonDialog1.filename
    End If
    '
    If Len(cEditFile) <> 0 Then
       nAppID = Shell("NotePad " + cEditFile, 1)
       AppActivate (nAppID)
    End If
    GoTo LoadNotePadFileExit
    '
LoadNotePadFileErr:
    ErrMsg Err, Error$, 0, cEditFile, "LoadNotePadFile"
    InitApp
    '
LoadNotePadFileExit:
    '
End Sub
Most of this code should look familiar. The first part of the routine in Listing A.24 sets up and activates the CommonDialog object to allow the user to select an existing file or create a new file. Once this is done, the routine forces Windows to load a new instance of the Notepad application, and then gives that application the focus. Now the user sees the Notepad application (with the selected file loaded, too!). The SQL-VB5 application resumes processing once it gains the focus again.
The next routine you need to add to SQLVBMOD is the global error handler. This routine (shown in Listing A.25) simply displays the error messages and waits for the user to click the OK button before it returns to the calling routine. Create a Public Sub called ErrMsg and enter the code in Listing A.25.
Type.gifListing A.25. Coding the ErrMsg routine.
Sub ErrMsg(nErr As Integer, cError As String, intLine As Integer, strLine As
arrow.gifString, cModule As String)
    '
    ' report an error to user
    '
    Dim cMsg As String
    '
    cMsg = "ErrNo:" + Chr(9) + Str(nErr) + Chr(13)
    cMsg = cMsg + "ErrMsg: " + Chr(9) + cError + Chr(13)
    cMsg = cMsg + "LineNo:" + Chr(9) + Str(intLine) + Chr(13)
    cMsg = cMsg + "Text: " + Chr(9) + strLine
    '

 
< previous page page_898 next page >

If you like this book, buy it!